﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using lcmyjobs.Model;
namespace lcmyjobs.BLL
{
	/// <summary>
	/// enterprise_top
	/// </summary>
	public partial class enterprise_top
	{
		private readonly lcmyjobs.DAL.enterprise_top dal=new lcmyjobs.DAL.enterprise_top();
		public enterprise_top()
		{}
         /// <summary>
        /// 固定会员
        /// </summary>
        /// <param name="enterprise_lid"></param>
        /// <param name="checktime">更改审核通过时间</param>
        /// <param name="status">更改状态为1 通过</param>
        /// <returns></returns>
        public int UpdateTop(int enterprise_top_id, DateTime topchecktime, int status)
        {
            return dal.UpdateTop(enterprise_top_id,topchecktime,status);
        }
        /// <summary>
        /// 获取单位固定信息
        /// </summary>
        /// <param name="atid">网站类别</param>
        /// <param name="currentPageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public DataSet GetTopInfo(int atid, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetTopInfo(atid,currentPageIndex,pageSize,out count);
        }
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int enterprise_top_id)
		{
			return dal.Exists(enterprise_top_id);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(lcmyjobs.Model.enterprise_top model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(lcmyjobs.Model.enterprise_top model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int enterprise_top_id)
		{
			
			return dal.Delete(enterprise_top_id);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string enterprise_top_idlist )
		{
			return dal.DeleteList(enterprise_top_idlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public lcmyjobs.Model.enterprise_top GetModel(int enterprise_top_id)
		{
			
			return dal.GetModel(enterprise_top_id);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public lcmyjobs.Model.enterprise_top GetModelByCache(int enterprise_top_id)
		{
			
			string CacheKey = "enterprise_topModel-" + enterprise_top_id;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(enterprise_top_id);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (lcmyjobs.Model.enterprise_top)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
          /// <summary>
        /// 获得数据列表,表2是企业名字
        /// </summary>
        public DataSet GetList(int enterprise_bid)
        {
            return dal.GetList(enterprise_bid);
        }
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.enterprise_top> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.enterprise_top> DataTableToList(DataTable dt)
		{
			List<lcmyjobs.Model.enterprise_top> modelList = new List<lcmyjobs.Model.enterprise_top>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				lcmyjobs.Model.enterprise_top model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new lcmyjobs.Model.enterprise_top();
					if(dt.Rows[n]["enterprise_top_id"]!=null && dt.Rows[n]["enterprise_top_id"].ToString()!="")
					{
						model.enterprise_top_id=int.Parse(dt.Rows[n]["enterprise_top_id"].ToString());
					}
					if(dt.Rows[n]["enterprise_bid"]!=null && dt.Rows[n]["enterprise_bid"].ToString()!="")
					{
						model.enterprise_bid=int.Parse(dt.Rows[n]["enterprise_bid"].ToString());
					}
					if(dt.Rows[n]["toptime"]!=null && dt.Rows[n]["toptime"].ToString()!="")
					{
						model.toptime=DateTime.Parse(dt.Rows[n]["toptime"].ToString());
					}
					if(dt.Rows[n]["price"]!=null && dt.Rows[n]["price"].ToString()!="")
					{
						model.price=decimal.Parse(dt.Rows[n]["price"].ToString());
					}
					if(dt.Rows[n]["status"]!=null && dt.Rows[n]["status"].ToString()!="")
					{
						model.status=int.Parse(dt.Rows[n]["status"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

